package com.yunshipei.wps;

import android.os.RemoteException;
import cn.wps.moffice.service.doc.Document;

/**
 * @author ：chenyunbiao
 */
public class FileOperations {

	private Document mDoc;
	private String id;
	
	public FileOperations(Document mDoc, String id) {
		this.mDoc = mDoc;
		this.id = id;
	}
	
	public void operation() {
		switch (id) {
		case "menu_id_close":
			try {
				mDoc.close();
			} catch (RemoteException e) {
				e.printStackTrace();
			}
			break;
		case "menu_id_save":
			try {
				mDoc.save(false);
			} catch (RemoteException e) {
				e.printStackTrace();
			}
			break;
		case "menu_id_comment":
			try {
				if (mDoc.isInRevisionMode()) {
					mDoc.exitReviseMode();
				} else {
					mDoc.enterReviseMode();
				}
			} catch (RemoteException e) {
				e.printStackTrace();
			}
			break;
		case "menu_id_protect":
			try {
				if (mDoc.isProtectOn()) {
					mDoc.unprotect("123");
				} else {
					mDoc.protect("123", 3, true);
				}				
			} catch (RemoteException e) {
				e.printStackTrace();
			}
			break;
		case "menu_id_handwrite":
			try {
				mDoc.toggleInkFinger();
			} catch (RemoteException e) {
				e.printStackTrace();
			}
			break;
		default:
			break;
		}
	}
}
